<template>
	<uni-popup ref="popup" :background-color="bgColor" @maskClick="close">
		<slot></slot>
	</uni-popup>
</template>

<script>
	export default {
		props: {
			show: {
				default: false
			},
			type: {
				default: "center"
			},
			bgColor: {
				default: "#fff"
			}
		},
		watch: {
			show() {
				if (this.show) {
					this.$refs.popup.open(this.type)
				} else {
					this.close()
				}
			}
		},
		data() {
			return {

			}
		},
		methods: {
			close() {
				this.$refs.popup.close()
				this.$emit("update:show", false)
			}
		}
	}
</script>

<style lang="scss">

</style>